import logo from './logo.svg'
import './App.css'
import { BrowserRouter, Switch, Route } from 'react-router-dom'
import {connect} from 'react-redux'
function App(props) {
  const {globalState,dispatch} = props
  const setGlobalState = ()=>{
    dispatch({
      type:'setGlobalState',
      payload:{name:'xiaohuang',age:7}
    })
  }
  return (
    <div className="App">
        {/* <img src={logo} className="App-logo" alt="logo" /> */}
        <p>{JSON.stringify(globalState)}</p>
        <button onClick={setGlobalState}>setGlobalState</button>
        <BrowserRouter
          basename={window.__POWERED_BY_QIANKUN__ ? '/app-react' : '/'}
        >
          <Switch>
            <Route
              path="/a"
              render={(props) => <div {...props}>react-router-a</div>}
            ></Route>
            <Route
              path="/b"
              render={(props) => <div {...props}>react-router-b</div>}
            ></Route>
          </Switch>
        </BrowserRouter>
    </div>
  )
}

export default connect(({globalState})=>({globalState}))(App)
